<template>
  <el-form
    :rules="rules"
    class="login-container"
    label-position="left"
    label-width="0px"
    v-loading="loading"
  >
    <h3 class="login_title">系统登录</h3>
    <el-form-item prop="account">
      <el-input
        type="text"
        v-model="loginForm.username"
        auto-complete="off"
        placeholder="账户"
      ></el-input>
    </el-form-item>
    <el-form-item prop="password">
      <el-input
        size="normal"
        type="password"
        v-model="loginForm.password"
        auto-complete="off"
        placeholder="密码"
      ></el-input>
    </el-form-item>
    <el-checkbox
      size="normal"
      class="login_remember"
      v-model="checked"
      label-position="left"
      >记住密码</el-checkbox
    >
    <el-form-item>
      <el-button
        size="normal"
        type="primary"
        style="width: 100%"
        @click="submitLogin"
        >登录</el-button
      ></el-form-item
    >
  </el-form>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      rules: {
        account: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
      checked: true,
      vcUrl: "/verifyCode?time=" + new Date(),
      loginForm: {
        username: "admin",
        password: "123",
      },
      loading: false,
    };
  },
  methods: {
    submitLogin: function () {
      var _this = this;
      this.loading = true;
      this.postRequest("/doLogin", this.loginForm).then((resp) => {
        _this.loading = false;
        if (resp && resp.status == 200) {
          var data = resp.data;
          _this.$store.commit("login", data.obj);
          var path = _this.$$route.query.redirect;
          _this.$router.replace({
            path: path == "/" || path == undefined ? "/home" : path,
          });
        }
      });

      //
    
    },
  },
};
</script>

<style>
.login-container {
  border-radius: 15px;
  background-clip: padding-box;
  margin: 180px auto;
  width: 350px;
  padding: 15px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}

.login-title {
  margin: 15px auto 20px auto;
  text-align: center;
  color: #505458;
}

.login-remember {
  text-align: left;
  margin: 0px 0px 15px 0px;
}

</style>
